from PyQt5.QtWidgets import QWidget, QVBoxLayout, QPushButton
from PyQt5.QtGui import QIcon
from PyQt5.QtCore import Qt

class Sidebar(QWidget):
    def __init__(self, parent=None):
        super().__init__(parent)
        self.setup_ui()
    
    def setup_ui(self):
        """设置左侧栏界面"""
        layout = QVBoxLayout()
        layout.setContentsMargins(0, 0, 0, 0)
        layout.setSpacing(5)
        
        # 搜索图标按钮
        self.search_btn = QPushButton()
        self.search_btn.setIcon(QIcon("resources/icons/search.svg"))
        self.search_btn.setFixedSize(50, 50)
        self.search_btn.setToolTip("搜索")
        
        # 文件夹图标按钮
        self.folder_btn = QPushButton()
        self.folder_btn.setIcon(QIcon("resources/icons/folder_simple.svg"))
        self.folder_btn.setFixedSize(50, 50)
        self.folder_btn.setToolTip("文件浏览器")
        
        # 添加到布局
        layout.addWidget(self.search_btn)
        layout.addWidget(self.folder_btn)
        layout.addStretch()  # 添加弹性空间
        
        self.setLayout(layout)
    
    def get_stylesheet(self):
        """返回左侧栏的样式表"""
        return """
            QWidget {
                background-color: #2c3e50;
                border-right: 1px solid #3498db;
            }
            
            QPushButton {
                background-color: transparent;
                border: none;
                border-radius: 5px;
            }
            
            QPushButton:hover {
                background-color: #34495e;
            }
            
            QPushButton:pressed {
                background-color: #2980b9;
            }
        """